PyIgnition

https://github.com/animatinator/PyIgnition update for Python 3
Clone: git clone https://git.frombelow.net/PyIgnition.git
Log | Files | Refs | README

PyIgnition test - fire.py (1969B)


      1 # PyIgnition test
      2 
      3 import PyIgnition, pygame, sys
      4 
      5 
      6 screen = pygame.display.set_mode((800, 600))
      7 pygame.display.set_caption("PyIgnition demo: fire")
      8 clock = pygame.time.Clock()
      9 
     10 fire = PyIgnition.ParticleEffect(screen, (0, 0), (800, 600))
     11 gravity = fire.CreateDirectedGravity(strength = 0.07, direction = [0, -1])
     12 wind = fire.CreateDirectedGravity(strength = 0.05, direction = [1, 0])
     13 source = fire.CreateSource((300, 500), initspeed = 2.0, initdirection = 0.0, initspeedrandrange = 1.0, initdirectionrandrange = 0.5, particlesperframe = 10, particlelife = 100, drawtype = PyIgnition.DRAWTYPE_CIRCLE, colour = (255, 200, 100), radius = 3.0)
     14 source.CreateParticleKeyframe(10, colour = (200, 50, 20), radius = 4.0)
     15 source.CreateParticleKeyframe(30, colour = (150, 0, 0), radius = 6.0)
     16 source.CreateParticleKeyframe(60, colour = (50, 20, 20), radius = 20.0)
     17 source.CreateParticleKeyframe(80, colour = (0, 0, 0), radius = 50.0)
     18 rect = fire.CreateRectangle((400, 100), (200, 100, 100), bounce = 0.2, width = 100, height = 20)
     19 rect.CreateKeyframe(frame = 500, pos = (400, 250), width = 200, height = 30)
     20 #fire.CreateCircle((350, 200), (200, 100, 100), bounce = 0.2, radius = 25)
     21 #fire.CreateCircle((450, 200), (200, 100, 100), bounce = 0.2, radius = 25)
     22 
     23 # Test shizz for generic keyframe creation function
     24 #source.CreateParticleKeyframe(2, colour = (0, 0, 255))
     25 #source.CreateParticleKeyframe(5, colour = (0, 0, 0))
     26 #source.CreateParticleKeyframe(0, colour = (255, 255, 255))
     27 #source.CreateParticleKeyframe(0, colour = (0, 255, 0))
     28 #source.CreateParticleKeyframe(80, colour = (255, 255, 255), radius = 1.0)
     29 
     30 fire.SaveToFile("Fire.ppe")
     31 
     32 
     33 while True:
     34 	for event in pygame.event.get():
     35 		if event.type == pygame.QUIT:
     36 			sys.exit()
     37 	
     38 	screen.fill((0, 0, 0))
     39 	source.SetPos(pygame.mouse.get_pos())
     40 	if source.curframe % 30 == 0:
     41 		source.ConsolidateKeyframes()
     42 	fire.Update()
     43 	fire.Redraw()
     44 	pygame.display.update()
     45 	clock.tick(30)